<%--
  Created by IntelliJ IDEA.
  User: 林淮
  Date: 2024/12/2
  Time: 下午2:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<form action="uploadEmp" enctype="multipart/form-data" method="post">
    <label for="name">员工姓名:</label>
    <input type="text" id="name" name="name">
    <br>
    <label for="pwd">员工密码:</label>
    <input type="password" id="pwd" name="pwd">
    <br>
    <label for="rpwd">确认密码:</label>
    <input type="password" id="rpwd" name="rpwd">
    <br>
    <label for="img">员工头像:</label>
    <input type="file" id="img" name="img">
    <br>
    <label for="depteid">所属部门:</label>
    <select name="depteid" id="depteid">
        <option value="-1">请选择部门</option>
        <c:forEach items="${depts}" var="dept">
            <option value="${dept.depteid}">${dept.name}</option>
        </c:forEach>
    </select>
    <input type="submit" value="上传">
</form>
</body>
<script src="js/jquery3.6.4.js"></script>
<script>
    $(function () {
        $("#myForm").submit(function () {
            let deptId = $(this.depteid).val();
            if (deptId === -1) {
                alert("请选择部门");
                return false;
            }
            let pwd = $(this.pwd).val();
            let rpwd = $(this.rpwd).val();
            if (pwd === "") {
                alert("密码不能为空");
                return false;
            } else if (pwd !== rpwd) {
                alert("密码不一致");
                return false;
            }
            return true;
        })
    })
</script>
</html>
